<table class="table table-hover">
    <thead>
    <tr>
{{--        <th><input type="checkbox" class="grid-select-all" />&nbsp;</th>--}}
        <th>站点</th>
        <th>SKU</th>
        <th>季节性</th>
        <th>品类</th>
        <th>在库</th>
        <th>在途</th>
        <th>保留</th>
        <th>产品名称</th>
        <th>操作</th>
    </tr>
    <tr style="color:#f56f9c">
{{--        <td></td>--}}
        <td>TTL</td>
        <td></td>
        <td></td>
        <td></td>
        <td>{{ array_key_exists('instant',$total) ? $total['instant'] : '' }}</td>
        <td>{{ array_key_exists('area_transit',$total) ? $total['area_transit'] : '' }}</td>
        <td>{{ array_key_exists('reserve',$total) ? $total['reserve'] : '' }}</td>
        <td></td>
        <td></td>
    </tr>
    </thead>
    <tbody>
    @foreach($paginator as $row)
        <tr>
{{--            <td>--}}
{{--                @if($row->instant > 0)--}}
{{--                    <input type="checkbox" class="grid-row-checkbox" data-id="{{ $row->id }}" />--}}
{{--                @endif--}}
{{--            </td>--}}
            <td>{{ $row->area->area ?? '' }}</td>
            <td>{{ $row->sku->psku_code ?? '' }}</td>
            <td>{{ App\Models\Product\ProductClassify::$_season[$row->sku->classify->season ?? 3] }}</td>
            <td>{{ $row->sku->classify->title ?? '' }}</td>
            <td>{{ $row->instant }}</td>
            <td>{{ $row->area_transit }}</td>
            <td>{{ $row->reserve }}</td>
            <td>{{ $row->sku->psku_cn ?? '' }}</td>
            <td><button class="btn btn-xs btn-info t-modal" {{ $row->instant > 0 ? '' : 'disabled' }} data-id="{{ $row->id }}">挪用</button></td>
        </tr>
    @endforeach
    </tbody>
</table>
<div class="modal fade" id="tModal">
    <div class="modal-dialog">
        <div class="modal-content">
            <!-- 内容会加载到这里 -->
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<script language="JavaScript" type="text/javascript">
    $(function () {
        $('.t-modal').on('click', function(e) {
            e.preventDefault();
            var id = $(this).data('id');
            $("#tModal").modal({
                remote : '/xqc/inventory/transfer-ap-modal?action=transferModal&param=' + id
            });
        });
        $("#tModal").on("hidden.bs.modal", function() {
            $(this).removeData("bs.modal");
            $(this).find(".modal-content").children().remove();
        });

        $('.grid-row-check').on('click', function() {
            var id = $(this).data('id');
            $.ajax({
                method: 'post',
                url: '/xqc/inventory/transfer-ap-ajax',
                data: {
                    _token:"{{ csrf_token() }}",
                    param: id,
                    action: 'transfer'
                },
                success: function (data) {
                    if (typeof data === 'object') {
                        if (data.status) {
                            toastr.success('提交成功 !');
                            $.pjax.reload('#pjax-container');
                        } else {
                            swal(data.message, '', 'error');
                        }
                    }
                }
            });
        });
        // $('.grid-row-checkbox').iCheck({checkboxClass:'icheckbox_minimal-blue'}).on('ifChanged', function () {
        //     if (this.checked) {
        //         $(this).closest('tr').css('background-color', '#ffffd5');
        //     } else {
        //         $(this).closest('tr').css('background-color', '');
        //     }
        // });
        // $('.grid-select-all').iCheck({checkboxClass:'icheckbox_minimal-blue'});
        // $('.grid-select-all').on('ifChanged', function(event) {
        //     if (this.checked) {
        //         $('.grid-row-checkbox').iCheck('check');
        //     } else {
        //         $('.grid-row-checkbox').iCheck('uncheck');
        //     }
        // });

    });
</script>
